﻿namespace CodeParser.Tokens
{
    public class HlslSingleChars
        : TokenParser
    {

        public override Token GetTokenAt(string source, int index)
        {
            var ch = source[index];
            switch (ch)
            {
                case '(': return new Token() { Index = index, Type = TokenType.RoundOpen, Value = "(" };
                case ')': return new Token() { Index = index, Type = TokenType.RoundClose, Value = ")" };
                case '[': return new Token() { Index = index, Type = TokenType.SquareOpen, Value = "[" };
                case ']': return new Token() { Index = index, Type = TokenType.SquareClose, Value = "]" };
                case '{': return new Token() { Index = index, Type = TokenType.CurlyOpen, Value = "{" };
                case '}': return new Token() { Index = index, Type = TokenType.CurlyClose, Value = "}" };
                case ';': return new Token() { Index = index, Type = TokenType.SemiColon, Value = ";" };
                case '?': return new Token() { Index = index, Type = TokenType.QuestionMark, Value = "?" };
                case ':': return new Token() { Index = index, Type = TokenType.Colon, Value = ":" };
                case ',': return new Token() { Index = index, Type = TokenType.Comma, Value = "," };
            }
            return null;
        }

    }
}
